<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui-2.4.2/src/css/layui.css">
    <script type="text/javascript" src="/jquery/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/layui-2.4.2/src/layui.js"></script>
</head>
<body>
<div>
    <div class="layui-row">
        <div class="layui-form">
            <div class="layui-form-item">

                <label class="layui-form-label">转出方id:</label>
                <div class="layui-input-inline">
                    <input type="text" id="changeOutUserId" name="changeOutUserId" required
                           lay-verify="required"
                           placeholder="请输入转出方id"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">转入方id:</label>
                <div class="layui-input-inline">
                    <input type="text" id="changeInUserId" name="changeInUserId"
                           placeholder="请输入转入方id"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">转账日期:</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="flow-year" name="createTime" placeholder="选择日期"
                           style="width: 55% ">
                </div>
                <label class="layui-form-label">订单状态:</label>
                <div class="layui-input-inline">
                    <select name="orderStatus" class="orderStatus" >
                        <option value="-1">请选择</option>
                        <option value="0">转账中</option>
                        <option value="1">已完成</option>
                        <option value="2">已取消</option>
                    </select>
                </div>
                <button class="layui-btn" id="search">搜索</button>
                <button class="layui-btn" id="export">导出</button>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <table id="user_list_view" lay-filter="user_filter">

        </table>
    </div>
</div>
</body>
<form class="layui-form" id="edit_remark" action="" style="display:none;margin-top: 30px;">
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block" style="margin-right: 20px;">
            <input type="text" name="remark" id="remark" required  lay-verify="required" placeholder="请输入备注" class="layui-input">
        </div>
    </div>
</form>
<script type="text/html" id="toolOper">

    {{#  if(d.orderStatus == 0){ }}
    <a class="layui-btn layui-btn-xs" lay-event="cancel">取消订单</a>
    {{#  } }}


</script>

<script type="text/javascript" src="js/common/UILab/layui2.4.5/layui.js"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //按日查询
        laydate.render({
            elem: '#flow-year'
            , max: 0
            , format: 'yyyy-MM-dd'
            , done: function (value, date, endDate) {
                flowYmd = value;
            }
        });
    });
</script>

<script>
    layui.use(['element', 'table', 'upload', 'laytpl', 'form'], function () {
        var table = layui.table;
        table.render({
            elem: '#user_list_view',
            url: '/transferAccounts/queryList',
            page: true,
            limit: 10,
            limits: [10, 20, 50, 100],
            cols: [
                [
                    {field: 'accountIdOut', title: '转出方账户id',},
                    {field: 'nickNameOut', title: '转出方用户昵称',},
                    {field: 'realNameOut', title: '转出方实名', },
                    {field: 'mobileOut', title: '转出方手机号', },
                    {field: 'honeySugar', title: '蜜糖数量',},
                    {field: 'honeyFees', title: '手续费',},
                    {field: 'accountIdIn', title: '转入方账户id', },
                    {field: 'nickNameIn', title: '转入方用户昵称', },
                    {field: 'realNameIn', title: '转入方实名', },
                    {field: 'mobileIn', title: '转入方手机号', },
                    {field: 'createTime', title: '转账日期', },
                    {field: 'orderStatus', title: '订单状态',   templet: function (data) {
                            if (data.orderStatus === 0) return '转账中';
                            if (data.orderStatus === 1) return '已完成';
                            if (data.orderStatus === 2) return '已取消';
                        }},
                    {field: 'confirmType', title: '确认类型',  templet: function (data) {
                            if (data.confirmType === 0) return '手动确认';
                            if (data.confirmType === 1) return '系统确认';
                            if (data.confirmType === null ) return '未确认';
                        }},
                    {field: 'remark', title: '备注'},
                    {field: '', title: '操作', toolbar: '#toolOper'}

                ]
            ],
            response: {
                status: 'errorCode',
                countName: 'total',
                dataName: 'data'
            }
        });
        table.on('tool(user_filter)', function (obj) {
            var layEvent = obj.event;
            var id = obj.data.id;
            if (layEvent === 'cancel') {
                layer.open({
                    type: 1,
                    area: ['300px', '200px'],
                    content: $("#edit_remark"),
                    btn: ['保存', '取消'],
                    btnALign: 'c',
                    yes: function (index, layero) {
                        if ($("#remark").val() == '') {
                            alert('请输入备注');
                            return;
                        }
                        //拒绝。状态改为失败
                        //取消订单
                        $.ajax({
                            type: 'get',
                            data: {'id':id,'remark':$("#remark").val()},
                            url: '/transferAccounts/cancel',
                            cache: false,
                            success: function (data) {
                                layer.closeAll();
                                if (data.success == true) {
                                    $(".layui-laypage-btn").click();
                                }else{
                                    alert(data.msg);
                                }
                            }
                        })
                    },
                });
            }
        });
        $("#search").on('click', function () {
            table.reload('user_list_view', {
                url: '/transferAccounts/queryList',
                where: {
                    changeOutUserId: $('#changeOutUserId').val(),
                    changeInUserId: $('#changeInUserId').val(),
                    createTime: $('input[name="createTime"]').val(),
                    orderStatus: $('.orderStatus').val()
                }
            });
        });
        $("#export").on('click', function () {
            var changeOutUserId = $('#changeOutUserId').val();
            var changeInUserId = $('#changeInUserId').val();
            var createTime = $('input[name="createTime"]').val();
            var orderStatus = $('.orderStatus').val();
            window.location="/transferAccounts/export?&changeOutUserId="+changeOutUserId+"&changeInUserId="+changeInUserId+"&createTime="+createTime+"&orderStatus="+orderStatus;
        });

    });
</script>
</html>